<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of LinkItem
 *
 * @author julien
 */
require_once 'Classes/View/ViewItems/ViewElement.php';
class LinkItem extends ViewElement{
    
    private $url;
    private $text;
    
    public function __construct($url, $text="") {
        $this->url = $url;
        if(is_a($text, 'ViewElement')){
            $this->text = $text;
        }
        else if($text != "") {
            $this->text = new TextFieldItem($text);
            $this->text->disableMarkups();
            
        }
        else {
            $this->text = new TextFieldItem($url);
            $this->text->disableMarkups();
        }
        
    }
    
    public function getHTML(){
       if($this->visible){
        
        $return = "";
        $return .= '<a ';
        $return .= $this->getClassAndIdStatement();
        $return .= 'href="'.$this->url.'" >'.$this->text->getHTML().'</a>';
        $return .= $this->getEndingSpace();
        return $return;
       }
        
    }
}

?>
